package com.szlanyou.thirdsdk.retrofit.file.download;

import android.view.View;

/**
 * 下载网络请求结果处理，封装对View的Enable处理。
 * @author: 陈章
 * function:
 */
public abstract class ClickViewRelatedHttpDownloadProgressResultHandler extends IHttpDownloadProgressResultHandler {
    /**
     * 点击发动网络请求的View
     */
    private View clickView;

    public ClickViewRelatedHttpDownloadProgressResultHandler(View clickView) {
        this.clickView = clickView;
    }

    public ClickViewRelatedHttpDownloadProgressResultHandler() {
    }

    @Override
    public void onStart(String requestPageFlag,String requestCode) {
        if (clickView != null) {
            clickView.setEnabled(false);
        }
    }

    @Override
    public void onCancel(String requestPageFlag,String requestCode) {
        if (clickView != null) {
            clickView.setEnabled(true);
        }
    }

    @Override
    public void onComplete(boolean causeByError) {
        if (clickView != null) {
            clickView.setEnabled(true);
        }
    }
}
